namespace IrisGenerator.Common.DatabaseModel.DataAccess
{
    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Data;
    using System.Xml;
    
    
    public partial class Table : IDisposable {
        
        private IrisGenerator.Dal.DataAccess _dataAccess;
        
        public Table() {
            this._dataAccess = new IrisGenerator.Dal.DataAccess();
        }
        
        public virtual System.Data.DataSet Select_TABLE_By_DB_ID(System.Nullable<System.Guid> DB_ID) {
            this._dataAccess.CreateProcedureCommand("sp_Select_TABLEs_By_DB_ID");
            this._dataAccess.AddParameter("DB_ID", DB_ID, ParameterDirection.Input);
            DataSet value = this._dataAccess.ExecuteDataSet();
            return value;
        }
        
        public virtual System.Data.DataSet TABLE_Select_All() {
            this._dataAccess.CreateProcedureCommand("sp_TABLE_Select_All");
            DataSet value = this._dataAccess.ExecuteDataSet();
            return value;
        }
        
        public virtual System.Data.DataSet TABLE_Select_One(System.Nullable<System.Guid> TAB_ID) {
            this._dataAccess.CreateProcedureCommand("sp_TABLE_Select_One");
            this._dataAccess.AddParameter("TAB_ID", TAB_ID, ParameterDirection.Input);
            DataSet value = this._dataAccess.ExecuteDataSet();
            return value;
        }
        
        public virtual System.Nullable<System.Guid> TABLE_Insert(System.Nullable<System.Guid> DB_ID, string TAB_NAME, string TAB_OWNER, string TAB_FORMATED_NAME, System.Nullable<bool> TAB_IS_VIEW) {
            this._dataAccess.CreateProcedureCommand("sp_TABLE_Insert");
            this._dataAccess.AddParameter("DB_ID", DB_ID, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_NAME", TAB_NAME, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_OWNER", TAB_OWNER, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_FORMATED_NAME", TAB_FORMATED_NAME, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_IS_VIEW", TAB_IS_VIEW, ParameterDirection.Input);
            Guid value = ((Guid)(this._dataAccess.ExecuteScalar()));
            return value;
        }
        
        public virtual System.Nullable<int> TABLE_Delete(System.Nullable<System.Guid> TAB_ID) {
            this._dataAccess.CreateProcedureCommand("sp_TABLE_Delete");
            this._dataAccess.AddParameter("TAB_ID", TAB_ID, ParameterDirection.Input);
            int value = this._dataAccess.ExecuteNonQuery();
            return value;
        }
        
        public virtual System.Nullable<int> TABLE_Update(System.Nullable<System.Guid> TAB_ID, System.Nullable<System.Guid> DB_ID, string TAB_NAME, string TAB_OWNER, string TAB_FORMATED_NAME, System.Nullable<bool> TAB_IS_VIEW) {
            this._dataAccess.CreateProcedureCommand("sp_TABLE_Update");
            this._dataAccess.AddParameter("TAB_ID", TAB_ID, ParameterDirection.Input);
            this._dataAccess.AddParameter("DB_ID", DB_ID, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_NAME", TAB_NAME, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_OWNER", TAB_OWNER, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_FORMATED_NAME", TAB_FORMATED_NAME, ParameterDirection.Input);
            this._dataAccess.AddParameter("TAB_IS_VIEW", TAB_IS_VIEW, ParameterDirection.Input);
            int value = this._dataAccess.ExecuteNonQuery();
            return value;
        }
        
        public virtual void Dispose() {
            if ((this._dataAccess != null)) {
                this._dataAccess.Dispose();
            }
        }
    }
}
